package net.seehealth.healthpad.application.adapter;

import java.util.ArrayList;
import java.util.List;

import net.seehealth.healthpad.ui.view.DiseaseRiskItemView;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class DiseaseRiskAdapter extends BaseAdapter {
	
	/** 所有数据 **/
	private List<String> mTitle;
	
	private List<String> mData;

	/** 当期上下文 **/
	private Context mContext;
	
	public DiseaseRiskAdapter(Context context) {
		mContext = context;
		mData = new ArrayList<String>();
		mTitle = new ArrayList<String>();
	}
	
	public void setTitleData(List<String> data) {
		mTitle.clear();
		mTitle.addAll(data);
	}

	
	public void setData(List<String> data) {
		mData.clear();
		mData.addAll(data);
	}

	@Override
	public int getCount() {
		return ((mData == null) ? 0 : mData.size());
	}

	@Override
	public Object getItem(int position) {
		return mData.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public void notifyDataSetChanged() {
		super.notifyDataSetChanged();
	}

	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = new DiseaseRiskItemView(mContext);
		}
		
		((DiseaseRiskItemView) convertView).updateView(mTitle.get(position), mData.get(position));

		return convertView;
	}
}
